		TITLE	MAPSUBS - Copyright (c) SLR Systems 1994

		INCLUDE	MACROS
		INCLUDE	SYMBOLS

		PUBLIC	RELEASE_EAX_BUFFER,HEADER_OUT,LINE_OUT,MOVE_SLEN,MOVEIT,SPACE_OUT


		.DATA

		EXTERNDEF	XOUTBUF:BYTE

		EXTERNDEF	QN_BUFFER:DWORD,EXP_BUFFER:DWORD

		EXTERNDEF	LOUTALL:DWORD


		.CODE	ROOT_TEXT

		EXTERNDEF	RELEASE_BLOCK:PROC,MOVE_ASCIZ_ESI_EDI:PROC


RELEASE_EAX_BUFFER	PROC
		;
		;
		;
		LEA	ECX,[EAX+4]
		XOR	EDX,EDX

		MOV	[EAX],EDX
TL_1:
		MOV	EAX,[ECX]
		MOV	[ECX],EDX

		TEST	EAX,EAX
		JZ	L9$

		ADD	ECX,4
		CALL	RELEASE_BLOCK

		JMP	TL_1

L9$:
		RET

RELEASE_EAX_BUFFER	ENDP

if	0

TBLINIT 	PROC
		;
		;
		;
		MOV	ECX,OFF QN_BUFFER+4	;TABLE OF BLOCKS OF INDEXES
		MOV	EAX,QN_BUFFER		;FIRST BLOCK

		MOV	WM_BLK_PTR,ECX		;POINTER TO NEXT BLOCK
;		MOV	WM_BLK,EAX		;FOR UNLOCKING

		TEST	EAX,EAX
		JZ	L9$
		;
		MOV	ECX,PAGE_SIZE/4		;# I HAVE PER BLOCK
		MOV	WM_PTR,EAX		;PHYSICAL POINTER TO NEXT INDEX TO PICK

		MOV	WM_CNT,ECX
		OR	AL,1
L9$:
		RET

TBLINIT 	ENDP


TBLNEXT 	PROC
		;
		;GET NEXT SYMBOL INDEX IN AX, DS:SI POINTS
		;
		MOV	EDX,WM_CNT
		MOV	ECX,WM_PTR

		DEC	EDX			;LAST ONE?
		JZ	L5$

		MOV	EAX,[ECX]		;NEXT INDEX
		ADD	ECX,4

		TEST	EAX,EAX
		JZ	L9$

		MOV	WM_PTR,ECX		;UPDATE POINTER
		MOV	WM_CNT,EDX		;UPDATE COUNT

L9$:
		RET

L5$:
		;
		;NEXT BLOCK
		;
		MOV	EAX,[ECX]
		MOV	ECX,WM_BLK_PTR

		MOV	WM_CNT,PAGE_SIZE/4

		MOV	EDX,[ECX]
		ADD	ECX,4


		MOV	WM_PTR,EDX
		MOV	WM_BLK_PTR,ECX

		TEST	EAX,EAX

		RET

TBLNEXT 	ENDP

endif

HEADER_OUT	PROC
		;
		;
		;
		XOR	ECX,ECX

		MOV	CL,[EAX]
		INC	EAX

		JMP	LOUTALL

;		RET

HEADER_OUT	ENDP


LINE_OUT	PROC
		;
		;ALWAYS RETURNS WITH CARRY CLEAR
		;
		MOV	EAX,0A0DH
		LEA	ECX,[EDI+2]

		MOV	[EDI],EAX
		MOV	EAX,OFF XOUTBUF

		PUSH	EAX
		SUB	ECX,EAX

		CALL	LOUTALL 	;OUTPUT THIS...

		POP	EDI

		RET

LINE_OUT	ENDP


MOVE_SLEN	PROC
		;
		;
		;
		LEA	ESI,[ECX].SYMBOL_STRUCT._S_NAME_TEXT
		JMP	MOVE_ASCIZ_ESI_EDI

;		RET

MOVE_SLEN	ENDP


MOVEIT		PROC
		;
		;
		;
		XOR	ECX,ECX

		MOV	CL,[ESI]
		INC	ESI

		OPTI_MOVSB

		RET

MOVEIT		ENDP


SPACE_OUT	PROC
		;
		;STORE AT LEAST 1 SPACE
		;
		SUB	ECX,EDI
		JBE	L5$

		MOV	EAX,'    '
		OPTI_STOSB

		RET

L5$:
		MOV	BPTR [EDI],' '
		INC	EDI

		RET

SPACE_OUT	ENDP


if	0

		.DATA?

		ALIGN	4

WM_PTR		DD	?
WM_CNT		DD	?
WM_BLK_PTR	DD	?

endif

		END

